Activate suspending/resuming of the TPM interface and add
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 5 Oct 2005 22:15:00 +0000 (23:15 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Wed, 5 Oct 2005 22:15:00 +0000 (23:15 +0100)
some missing code to tpmif.py.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c
tools/python/xen/xend/server/tpmif.py

index 55c44f95aafb89ca8ee9d296471a4fe7aa7c018b..384f39ffcb6565f89592e5734c336b08acd3fc23 100644 (file)
@@ -442,26 +442,32 @@ static int tpmfront_remove(struct xenbus_device *dev)
        return 0;
 }
 
-static int tpmfront_suspend(struct xenbus_device *dev)
+static int
+tpmfront_suspend(struct xenbus_device *dev)
 {
        struct tpmfront_info *info = dev->data;
        struct tpm_private *tp = &my_private;
+       u32 ctr = 0;
 
-       /* lock so no app can send */
+       /* lock, so no app can send */
        down(&suspend_lock);
 
-       while (atomic_read(&tp->tx_busy)) {
-               printk("---- TPMIF: Outstanding request.\n");
-#if 0
+       while (atomic_read(&tp->tx_busy) && ctr <= 25) {
+               if ((ctr % 10) == 0)
+                       printk("INFO: Waiting for outstanding request.\n");
                /*
-                * Would like to wait until the outstanding request
-                * has come back, but this does not work properly, yet.
+                * Wait for a request to be responded to.
                 */
-               interruptible_sleep_on_timeout(&tp->wait_q,
-                                              100);
-#else
-               break;
-#endif
+               interruptible_sleep_on_timeout(&tp->wait_q, 100);
+               ctr++;
+       }
+
+       if (atomic_read(&tp->tx_busy)) {
+               /*
+                * A temporary work-around.
+                */
+               printk("WARNING: Resetting busy flag.");
+               atomic_set(&tp->tx_busy, 0);
        }
 
        unregister_xenbus_watch(&info->watch);
@@ -469,44 +475,34 @@ static int tpmfront_suspend(struct xenbus_device *dev)
        kfree(info->backend);
        info->backend = NULL;
 
-       destroy_tpmring(info, tp);
-
-       return 0;
-}
-
-static int tpmif_recover(void)
-{
        return 0;
 }
 
-static int tpmfront_resume(struct xenbus_device *dev)
+static int
+tpmfront_resume(struct xenbus_device *dev)
 {
        struct tpmfront_info *info = dev->data;
-       int err;
+       int err = talk_to_backend(dev, info);
 
-       err = talk_to_backend(dev, info);
-       if (!err) {
-               tpmif_recover();
-       }
-
-       /* unlock so apps can resume */
+       /* unlock, so apps can resume sending */
        up(&suspend_lock);
 
        return err;
 }
 
-static void tpmif_connect(u16 evtchn, domid_t domid)
+static void
+tpmif_connect(u16 evtchn, domid_t domid)
 {
        int err = 0;
        struct tpm_private *tp = &my_private;
 
        tp->evtchn = evtchn;
-       tp->backend_id  = domid;
+       tp->backend_id = domid;
 
-       err = bind_evtchn_to_irqhandler(
-               tp->evtchn,
-               tpmif_int, SA_SAMPLE_RANDOM, "tpmif", tp);
-       if ( err <= 0 ) {
+       err = bind_evtchn_to_irqhandler(tp->evtchn,
+                                       tpmif_int, SA_SAMPLE_RANDOM, "tpmif",
+                                       tp);
+       if (err <= 0) {
                WPRINTK("bind_evtchn_to_irqhandler failed (err=%d)\n", err);
                return;
        }
@@ -641,7 +637,7 @@ tpm_xmit(struct tpm_private *tp,
 
                if (NULL == txb) {
                        DPRINTK("txb (i=%d) is NULL. buffers initilized?\n", i);
-                       DPRINTK("Not transmittin anything!\n");
+                       DPRINTK("Not transmitting anything!\n");
                        spin_unlock_irq(&tp->tx_lock);
                        return -EFAULT;
                }
index 50e8f7f016a739f5635154f780e6a690c5a283e2..b5269a2cb075090bc01748f9c892ecdd2456d059 100644 (file)
@@ -39,9 +39,24 @@ class TPMifController(DevController):
         """@see DevController.getDeviceDetails"""
         
         devid = int(sxp.child_value(config, 'instance', '0'))
-        log.debug("The domain has a TPM with instance %d." % devid)
+        log.info("The domain has a TPM with instance %d." % devid)
 
         back  = { 'instance' : "%i" % devid }
         front = { 'handle' : "%i" % devid }
 
         return (devid, back, front)
+
+    def configuration(self, devid):
+
+        log.info("The configuration method is called.")
+
+        result = DevContoller.configuration(self, devid)
+
+        (instance) = self.readBackend(devif,
+                                      'instance')
+
+        if instance:
+            result.append(['instance', instance])
+            log.info("configuration: instance=%d." % instance)
+
+        return result